package org.martin.snsrs.services;

import java.util.ArrayList;
import java.util.List;

import org.martin.snsrs.beans.Activity;
import org.martin.snsrs.beans.ActivityTags;
import org.martin.snsrs.beans.Tags;
import org.martin.snsrs.daos.ActivityDao;

import org.martin.snsrs.daos.TagsDao;

import com.sun.jndi.url.ldaps.ldapsURLContextFactory;

public class TagService {
	
	private TagsDao tagsDao;
	
	private ActivityDao activityDao;
	
	public void saveActivityTags(String activityName, List<String> tagName){
		Activity activity = activityDao.getActivityByName(activityName);
		if(activity == null)
			return;
		for(String name : tagName){
			ActivityTags tag = new ActivityTags();
			tag.setActivities(activity);
			Tags tags = tagsDao.getTagByName(name);
			if(tags == null)
				continue;
			else {
				tag.setTags(tags);
				tagsDao.saveActivityTags(tag);
			}
		}
	}
}
